<?php

class FormFilter_String extends FormFilter
{

  public function injectQueryParams(&$params)
  {
    $val = $this->getValue();

    if (empty($val) && $this->required) {
      s::getInstance()->warnings('Select the ' . $this->getTitle());
      s::response()->redirect(array($this->redirect, $this->redirectParams));
    }

    if (! empty($val) || $this->required) {
      $key = $this->getForeignKey();

      $params['where'][] = "$key LIKE :$key";
      $params['data'][$key] = '%' . $val . '%';
      $params['fields'][] = $key;
    }
  }

  public function getTemplate()
  {
    /*$template = parent::getTemplate();

    if (empty($template)) {*/
      global $config;

      $template = $config['views_dir'] . '/form/form_filter_string_view.php';
    //}

    return $template;
  }

}

?>